﻿@using FujiyBlog.Web.Models
@functions{
    public string FeedsUrl()
    {
        if (!string.IsNullOrWhiteSpace(Settings.SettingRepository.AlternateFeedUrl))
        {
            return Settings.SettingRepository.AlternateFeedUrl;
        }
        return Settings.SettingRepository.DefaultFeedOutput == "RSS" ? Url.Action(MVC.Feed.Rss20()) : Url.Action(MVC.Feed.Atom10());
    }

    public string CanonicalUrl()
    {
        RouteValueDictionary valores = new RouteValueDictionary(ViewContext.RouteData.Values);
        foreach (KeyValuePair<string, ModelState> keyValuePair in ViewContext.ViewData.ModelState.Where(x => x.Value.Value != null))
        {
            valores[keyValuePair.Key] = keyValuePair.Value.Value.AttemptedValue;
        }

        return Url.RouteUrl(null, valores, Request.Url.Scheme, null);
    }

}
<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
    @Styles.Render("~/Content/Themes/Default/css")
    @Styles.Render("~/Content/Themes/base/css")
    @Styles.Render("~/Content/openid/css")
    <link rel="canonical" href="@CanonicalUrl()" />

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="title" content="@ViewBag.Title" />
    <meta name="keywords" content="@ViewBag.Keywords" />
    <meta name="description" content="@ViewBag.Description" />

    <link type="application/rss+xml" rel="alternate" href="@FeedsUrl()" />

    @if (!string.IsNullOrEmpty(@Settings.SettingRepository.FacebookAdminIds))
    {
        <meta property="fb:admins" content="@Settings.SettingRepository.FacebookAdminIds" />
    }
    @if (!string.IsNullOrEmpty(@Settings.SettingRepository.FacebookAppId))
    {
        <meta property="fb:app_id" content="@Settings.SettingRepository.FacebookAppId" />
    }
    <meta property="og:site_name" content="@Settings.SettingRepository.BlogName" />

    @if (IsSectionDefined("OpenGraphTags"))
    {
        @RenderSection("OpenGraphTags")
    }
    else
    {
        <meta property="og:title" content="@ViewBag.Title" />
        <meta property="og:type" content="blog" />
        <meta property="og:url" content="@Url.Action(MVC.Post.Index(), Request.Url.Scheme)" />
        <meta property="og:image" content="@Settings.SettingRepository.OpenGraphImageUrl" />
        <meta property="og:description" content="@ViewBag.Description" />
    }

    @if (IsSectionDefined("TwitterCardsTags"))
    {
        @RenderSection("TwitterCardsTags")
    }
    else
    {
        <meta name="twitter:card" content="summary">
        <meta name="twitter:site" content="@Settings.SettingRepository.TwitterBlogAccount">
        <meta name="twitter:title" content="@ViewBag.Title">
        <meta name="twitter:description" content="@ViewBag.Description">
        <meta name="twitter:creator" content="">
        <meta name="twitter:image:src" content="@Settings.SettingRepository.OpenGraphImageUrl">
        <meta name="twitter:domain" content="@Url.Action(MVC.Post.Index(), Request.Url.Scheme)">
    }

</head>

<body>
    <div>
        <div id="header-wrapper">
            <div id="header-title">
                <h1><a href="@Url.Content("~/")">@Settings.SettingRepository.BlogName</a></h1>
                <p>@Settings.SettingRepository.BlogDescription</p>
            </div>
            <div id="menu">
                <ul>

                    <li class="@(Url.Action(MVC.Post.Index(), Request.Url.Scheme) == CanonicalUrl() ? " current_page_item" : "")"><a href="@Url.Content("~/")">Home</a></li>
                    <li class="@(Url.Action(MVC.Post.Archive(), Request.Url.Scheme) == CanonicalUrl() ? " current_page_item" : "")">@Html.ActionLink(Resources.Labels.Archive, MVC.Post.Archive())</li>
                    <li class="@(Url.Action(MVC.Contact.Index(), Request.Url.Scheme) == CanonicalUrl() ? " current_page_item" : "")">@Html.ActionLink(Resources.Labels.Contact, MVC.Contact.Index())</li>
                    <li><a href="@FeedsUrl()">Feed</a></li>
                    <li>@(Request.IsAuthenticated ? Html.ActionLink("Log Off", "LogOff", "Account") : Html.ActionLink("Log On", "LogOn", "Account"))</li>
                </ul>
            </div>
        </div>
        <div id="page">
            <div id="content">
                @RenderBody()
                <div style="clear: both;">&nbsp;</div>
            </div>

            <div id="sidebar">
                <ul id="sidebar-wrapper">
                    @Html.Action(MVC.Widget.Index("Zone1"))
                </ul>
            </div>
            <div style="clear: both;">&nbsp;</div>
        </div>
    </div>

    <div id="footer">
        <p><a href="http://www.fujiyblog.com/">FUJIYBLOG</a> v0.5</p>
    </div>

    <script src="@Url.Action(MVC.JavaScript.FujiyBlogBundle())" type="text/javascript"></script>
    @Scripts.Render("~/bundles/FujiyBlogBundle")
    @RenderSection("scripts", false)

    @if (!string.IsNullOrEmpty(Settings.SettingRepository.CustomCode))
    {
        @Html.Raw(Settings.SettingRepository.CustomCode)
    }

    @if (StackExchange.Profiling.MiniProfiler.Settings.Results_Authorize(HttpContext.Current.Request))
    {
        @StackExchange.Profiling.MiniProfiler.RenderIncludes(useExistingjQuery: true)
    }
</body>
</html>
